﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace lnxsj.web.Recruitment.Classes
{
    public class myAjaxResult
    {

            static JsonResult JsonResult = new JsonResult() { JsonRequestBehavior = JsonRequestBehavior.AllowGet };
            static Dictionary<string, object> data = new Dictionary<string, object>();

            public static JsonResult success(object content = null, resultActionEnum action = resultActionEnum.none, string jsonType = "applaction/json")
            {
                if (content == null) content = "成功";
                data["result"] = resultTypeEnum.SUCCESS.ToString();
                data["content"] = content;
                data["action"] = action.ToString();
                JsonResult.Data = data;
                if (jsonType != null)
                {
                    JsonResult.ContentType = jsonType;
                }
                return JsonResult;
            }

            public static JsonResult error(object content = null, resultActionEnum action = resultActionEnum.none, string jsonType = "applaction/json")
            {
                if (content == null) content = "失败";
                data["result"] = resultTypeEnum.ERROR.ToString();
                data["content"] = content;
                data["action"] = action.ToString();
                JsonResult.Data = data;
                if (jsonType != null)
                {
                    JsonResult.ContentType = jsonType;
                }
                return JsonResult;
            }

        }

    public enum resultTypeEnum
    {
        SUCCESS,
        ERROR,
    }

    public enum resultActionEnum
    {
        none,
        reload,
        updata,
        relogin
    }
}